/**
 * 
 * File: SystemContext.java
 *   
 * Copyright (C): 2009
 *
 * Description:
 * <<本类负责提取分页参数>>
 *
 *
 * Revision History:
 * <<Date>>, <<Who>>, <<What>> 
 */
package com.yypx.common.navigation;


/**
 * @author Zz
 * @version 1.0
 * @since 2009-09-02
 * 
 */
public class SystemContext {
	/**
	 * 分页起始点
	 */
	public static ThreadLocal<Integer> offset = new ThreadLocal<Integer>();
	/**
	 * 分页数
	 */
	public static ThreadLocal<Integer> pagesize = new ThreadLocal<Integer>();
	/**
	 * 做多显示分页的页码
	 */
	public static ThreadLocal<Integer> maxIndexPages = new ThreadLocal<Integer>();

	public static void setOffset(int offsetValue) {
		offset.set(offsetValue);
	}

	public static int getOffset() {
		Integer os = offset.get();
		if (os == null) {
			return 0;
		}
		return os;
	}

	public static void removeOffset() {
		offset.remove();
	}

	public static void setPagesize(int pagesizeValue) {
		pagesize.set(pagesizeValue);
	}

	public static int getPagesize() {
		Integer ps = pagesize.get();
		if (ps == null) {
			return 10;
//			return Integer.MAX_VALUE;
		}
		return ps;
	}

	public static void removePagesize() {
		pagesize.remove();
	}

	public static void setMaxIndexPages(int maxIndexPagesValue) {
		maxIndexPages.set(maxIndexPagesValue);
	}

	public static int getMaxIndexPages() {
		Integer is = maxIndexPages.get();
		if (is == null) {
			return 5;
			//return Integer.MAX_VALUE;
		}
		return is;
	}

	public static void removeMaxIndexPages() {
		maxIndexPages.remove();
	}

}
